/**
 * 
 */
package systole.view.crud.tableModels;

import java.util.Date;
import java.util.List;

import systole.domain.clinicalInformation.ClinicalInformation;

/**
 * @author jmj
 * 
 */
public class ClinicalInfoTableModel extends SystoleTableModel<ClinicalInformation> {

    private String[] columnNames = {"Fecha", "Glucemia", "LDL", "HDL", "Trigliceridos"};
    private static final int DATE_INDEX = 0;
    private static final int GLUCEMY_INDEX = 1;
    private static final int LDL_INDEX = 2;
    private static final int HDL_INDEX = 3;
    private static final int TRIGLYCERIDES_INDEX = 4;

    /**
     * @param clinicalInfo
     */
    public ClinicalInfoTableModel(List<ClinicalInformation> clinicalInfo) {
        super(clinicalInfo);
    }

    /*
     * (non-Javadoc)
     *
     * @see javax.swing.table.TableModel#getColumnClass(int)
     */
    @Override
    public Class<?> getColumnClass(int columnIndex) {
        switch (columnIndex) {
            case DATE_INDEX:
                return Date.class;
            case GLUCEMY_INDEX:
                return Float.class;
            case HDL_INDEX:
                return Float.class;
            case LDL_INDEX:
                return Float.class;
            case TRIGLYCERIDES_INDEX:
                return Float.class;
        }
        return null;
    }

    /*
     * (non-Javadoc)
     *
     * @see javax.swing.table.TableModel#getColumnCount()
     */
    @Override
    public int getColumnCount() {
        return this.columnNames.length;
    }

    /*
     * (non-Javadoc)
     *
     * @see javax.swing.table.TableModel#getColumnName(int)
     */
    @Override
    public String getColumnName(int columnIndex) {
        return this.columnNames[columnIndex];
    }


    /*
     * (non-Javadoc)
     *
     * @see javax.swing.table.TableModel#getValueAt(int, int)
     */
    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case DATE_INDEX:
                return this.entities.get(rowIndex).getInformationDate();
            case GLUCEMY_INDEX:
                return this.entities.get(rowIndex).getGlucemic();
            case HDL_INDEX:
                return this.entities.get(rowIndex).getHdl();
            case LDL_INDEX:
                return this.entities.get(rowIndex).getLdl();
            case TRIGLYCERIDES_INDEX:
                return this.entities.get(rowIndex).getTriglycerides();
        }
        return null;
    }

    /*
     * (non-Javadoc)
     *
     * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int)
     */
    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
      switch (columnIndex) {
            case DATE_INDEX:
                 this.entities.get(rowIndex).setInformationDate((Date) aValue);
                 break;
            case GLUCEMY_INDEX:
                 this.entities.get(rowIndex).setGlucemic((Float) aValue);
                 break;
            case HDL_INDEX:
                 this.entities.get(rowIndex).setHdl((Float) aValue);
                 break;
            case LDL_INDEX:
                 this.entities.get(rowIndex).setLdl((Float) aValue);
                 break;
            case TRIGLYCERIDES_INDEX:
                this.entities.get(rowIndex).setTriglycerides((Float) aValue);
                break;
        }
    }
}
